/*
 * Function: 
 */
package main;

import inporter.TokenArrayImporter;
import inporter.TokenInporter;

import java.util.ArrayList;
import java.util.Hashtable;

import nonDictionaryTokenAnalyzer.MainProcessor;
import dictionaryTokenScanner.TokenScanner;
import exporter.TextFileEditor;
import exporter.XmlFilePrinter;



public class Main 
{
	private static String strFileLocation = "input\\target.txt";
	private static String strDicLoc = "dictionary";
	
	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub
		TokenInporter clsTInporter = new TokenInporter();
		System.out.println("Initializing dictionary");
		TokenScanner clsScanner = new TokenScanner(strDicLoc);
		System.out.println("Initializing dictionary, Finished");
		
		
		System.out.println("Getting tokens from file");
		ArrayList<tokens> arlTokensArray = clsTInporter.arlInporter(strFileLocation);
		System.out.println("Getting tokens from file, Finished");
		
		System.out.println("Scanning dictionary tokens");
		//arlTokensArray = clsScanner.tokenScanner(arlTokensArray);
		System.out.println("Scanning dictionary tokens, Finished");
		
		
		//************************************************************
		//get Token Array from existed text file
		//System.out.println("Getting tokens from existed token array");
		TokenArrayImporter clsTAImporter = new TokenArrayImporter();
		arlTokensArray = clsTAImporter.arlInporter("input\\ArrayForRead.txt");
		//System.out.println("Getting tokens from existed token array, Finished");
		//**************************************************************
		
		System.out.println("Processing non-dictionary tokens");
		MainProcessor clsProcessor = new MainProcessor(clsTInporter.getCodeArray(), arlTokensArray);
		ArrayList<String> arlHashTableKeys = clsProcessor.nonDicTokenProcess();
		Hashtable<String, ArrayList<tokens>> htAlphaTokens = clsProcessor.getHashTable();
		System.out.println("Processing non-dictionary tokens, Finished");
		
		System.out.println("Printing out results XML file");
		XmlFilePrinter clsXMLPrinter = new XmlFilePrinter(arlHashTableKeys, htAlphaTokens);
		clsXMLPrinter.PrintResultIntoXML("output//Result.xml");
		System.out.println("Printing new txt file");
		TextFileEditor clsTFEditor = new TextFileEditor(htAlphaTokens);
		clsTFEditor.EditText("input\\target.txt", "output\\target_new.txt");
		System.out.println("Printing finished");
		
	}

}
